Source code for /engineering/webperf/slave-v4[j1.2]/Command.javaOriginal file Command.java
   1 import java.util.*;
   2 import java.io.*;
   3 
   4 public class Command extends Object {
   5   
   6    public static final int cmdNULL                 = 0;
   7    public static final int cmdSTOP                 = 1;
   8    public static final int cmdNEW	               = 2;
   9    public static final int cmdPAUSE		         = 3;
  10    public static final int cmdTARGET	         = 4;
  11    public static final int cmdGETLOG		   = 5;
  12    public static final int cmdGO			   = 6;
  13    public static final int cmdPING			   = 7;
  14 
  15    public static String cmdTextSTOP		   	   = "stop";
  16    public static String cmdTextNEW			   = "new";    // new-userstart-nil
  17    public static String cmdTextPAUSE		   = "pause";
  18    public static String cmdTextTARGET		   = "target";
  19    public static String cmdTextGETLOG		   = "getlog";
  20    public static String cmdTextGO			   = "go";
  21    public static String cmdTextPING			   = "ping"; 
  22 
  23    private int  		command; 
  24    private int    	intParam;
  25    private long 		longParam;
  26    private String 	stringParam;
  27    private Connection	connect;
  28    private String		protocol;
  29 
  30    public Command() {
  31 
  32    }
  33 
  34    public void setCommand(int  theCommand, int   intP,  long   longP,  String  stringP,
  35 			   Connection  inConnect, String  inProtocol) {
  36       
  37 	command 	= theCommand;
  38 	intParam	= intP;
  39 	longParam   = longP;
  40       stringParam = stringP;		// lets just hold the reference for now.
  41 	connect	= inConnect;	// let us respond to a request.
  42       protocol	= inProtocol;
  43    }
  44 
  45    public int getCommand() {
  46       return command;
  47    }
  48 
  49    public int getIntParam() {
  50       return intParam;
  51    }
  52 
  53    public long getLongParam() {
  54       return longParam;
  55    }
  56    
  57    public String getStringParam() {
  58       return stringParam;
  59    }
  60 
  61    public void respond(String  content) {
  62 
  63       try {
  64         connect.println(protocol.trim() + " 200 OK");
  65         connect.println("Server: JFPerf SLAVE");
  66         connect.println("Content-Type: text/html");
  67         connect.println("Content-Length: " + content.length());
  68         connect.println("Accept-ranges: bytes");
  69         connect.println("");
  70         connect.print(content);
  71         try { Thread.sleep(100); } catch (Exception e) {}
  72       } catch (IOException e) {
  73          System.out.println(e);
  74       }
  75       
  76       connect.close();	
  77    }
  78 
  79 }
  80